package com.tduck.cloud.form.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tduck.cloud.form.entity.UserFormEntity;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

/**
 * 表单表(Form)表数据库访问层
 *
 * @author smalljop
 * @since 2020-11-18 18:16:17
 */
public interface UserFormMapper extends BaseMapper<UserFormEntity> {

    /**
     * 查询表单和存储过程配置表
     * */
    @Select("SELECT PROCESS_NAME FROM FM_FORM_CONIG WHERE FORM_KEY = #{formKey}")
    String queryFormConfig(String formKey);

    /**
     * 查询系统配置表
     * */
    @Select("SELECT ENV_VALUE FROM SYS_ENV_CONFIG WHERE ENV_KEY = #{envKey}")
    String querySysConfig(String envKey);

    @Insert("INSERT INTO fm_user_form ( form_key, name, description, source_type, user_id, status, type, is_deleted, folder_id, create_time, update_time )\n" +
            "VALUES ( #{formKey, jdbcType=VARCHAR}, #{name, jdbcType=VARCHAR}, #{description, jdbcType=VARCHAR}, 0, #{userId, jdbcType=VARCHAR}, 0, 0, 0, 0, #{createTime, jdbcType=TIMESTAMP}, #{updateTime, jdbcType=TIMESTAMP} )")
    int insertForm(UserFormEntity userFormEntity);

}